the_grimoire_of_gaiafandomcom_ru-20200215-history
Модуль:Crafting
local p = {} function p.table( f ) local args = f if f mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge() else f = mw.getCurrentFrame() end local grid = require( 'Module:Grid' ) -- Start table when appropriate local multirow = f:callParserFunction( '#dplvar', 'multirow' ) if multirow ~= '1' then multirow = nil end local head = args.head or '' if multirow then head = '' elseif head ~= '' then multirow = 1 f:callParserFunction( '#dplvar:set', 'multirow', '1' ) else head = 1 end -- End table when appropriate local foot = args.foot or '' if multirow then if foot ~= '' then multirow = nil f:callParserFunction( '#dplvar:set', 'multirow', '0' ) end else foot = 1 end local header = '' if head ~= '' then local name = '' local description = '' if args.showname '1' or multirow and args.showname ~= '0' then name = 'Name !! ' f:callParserFunction( '#dplvar:set', 'craftingname', '1' ) end if args.showdescription '1' then description = ' !! class="unsortable" | Description' f:callParserFunction( '#dplvar:set', 'craftingdescription', '1' ) end local class = args.class or '' local recipeClass = '' if multirow then class = 'sortable collapsible ' .. class recipeClass = 'class="unsortable collapse-button" |' end header = table.concat( { ' ' f:callParserFunction( '#dplvar:set', 'craftingname', '0', 'craftingdescription', '0' ) end -- Create ingredient categories for DPL local title = mw.title.getCurrentTitle() local categories = '' if args.nocat ~= '1' and title.namespace 0 and not title.isSubpage then categories = {} if args.upcoming then table.insert( categories, 'Category:Upcoming' ) end if args.type then table.insert( categories, 'Category:' .. args.type .. ' recipe' ) end if args.ignoreusage ~= '1' then for k, v in ipairs( ingredientKeys ) do v = v:sub( 2 ) if not v:find( ':' ) then if v 'Any Dye' or v 'Any Colored Dye' then local dyes = { 'Orange Dye', 'Magenta Dye', 'Light Blue Dye', 'Dandelion Yellow', 'Lime Dye', 'Pink Dye', 'Gray Dye', 'Light Gray Dye', 'Cyan Dye', 'Purple Dye', 'Lapis Lazuli', 'Cocoa Beans', 'Cactus Green', 'Rose Red', 'Ink Sac' } if v 'Any Dye' then table.insert( dyes, 1, 'Bone Meal' ) end for _, dye in ipairs( dyes ) do table.insert( categories, 'Category:Recipe using ' .. dye .. '' ) end else if v 'Sticky Piston' then v = 'Piston' elseif v 'Any Mushroom' or v 'Red Mushroom' or v 'Brown Mushroom' then v = 'Mushroom' elseif v 'Red Sand' then v = 'Sand' elseif v 'Charcoal' then v = 'Coal' elseif v:find( ' Wood$' ) then v = 'Wood' elseif v:find( ' Wood Planks$' ) then v = 'Wood Planks' elseif v:find( ' Stained Glass$' ) then v = 'Stained Glass' elseif v:find( ' Stained Glass Pane$' ) then v = 'Stained Glass Pane' elseif v:find( ' Wool$' ) then v = 'Wool' elseif v:find( 'Red Sandstone$' ) then v = 'Red Sandstone' elseif v:find( ' Sandstone$' ) then v = 'Sandstone' elseif v:find( ' Stairs$' ) then v = 'Stairs' elseif v:find( ' Slab$' ) then v = 'Slab' elseif v:find( ' Pressure Plate$' ) then v = 'Pressure Plate' elseif v:find( ' Firework Star$' ) then v = 'Firework Star' elseif v:find( ' Stone Bricks$' ) then v = 'Stone Bricks' elseif v:find( ' Quartz Block$' ) then v = 'Block of Quartz' elseif v:find( ' Andesite$' ) then v = 'Andesite' elseif v:find( ' Diorite$' ) then v = 'Diorite' elseif v:find( ' Granite$' ) then v = 'Granite' end table.insert( categories, 'Category:Recipe using ' .. v .. '' ) end end end end categories = table.concat( categories, '' ) end if args.debug '1' then return ' ' .. header .. '\n' .. row .. '\n|-\n' .. footer .. categories .. ' ' else return header .. '\n' .. row .. '\n|-\n' .. footer .. categories end end return p